<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- <link rel="shortcut icon" href="img/logo.ico" /> -->
		<title>合作方等级</title>
    <link href="plugin/date/date.css" rel="stylesheet">
		<link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/nav.css" />
  </head>
  <body>
	  <!--导航-->
      <nav class="navbar navbar-inverse">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
  	          	<a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
          </div>

          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
            <ul class="nav navbar-nav" id="nav">

            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="change_pass.html">修改密码</a></li>
                  <li><a id="loginOut" href="#">退出登陆</a></li>
                </ul>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    <div class="container-fluid">
			<div class="row bcert-box">
        <ol class="breadcrumb">
          <li><a href="javascript:;">主页</a></li>
          <li>会员管理</li>
          <li class="active">合作方等级</li>
        </ol>
        <div class="table">
          <table class="table table-bordered table-striped" id="integralList">

          </table>
        </div>
      </div>
      <!-- 分页 -->
        <nav aria-label="...">
          <div class="">
            <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
          </div>
          <ul id="example"></ul>
        </nav>
    </div>

<!-- 编辑 -->
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" id="entinfo">
  <div class="modal-dialog modal-lg" role="document">
	  <div class="modal-content">
  	  <div class="modal-header">
  		<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
  		<h4 class="modal-title" id="myLargeModalLabel">编辑</h4>
  	  </div>
  	  <div class="modal-body" style="overflow:auto">
  		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">id</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text" readonly="readonly" class="form-control" id="partner_id" placeholder="id"></div>
  		  </div>
		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">合作方名称</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text" readonly="readonly" class="form-control" id="partner_name" placeholder="合作方等级名称"></div>
  		  </div>
  		  <!-- <div class="form-group">
  			  <label class="col-sm-4 control-label goods-lb-l">合作方等级名称</label>
  			  <div class="col-sm-8 goods-lb-r">
  				<select class="form-control drop-down" id="">
  				  <option value="0">请合作方等级名称</option>
  				  <option value="1">省级合作方</option>
  				  <option value="2">市级合作方</option>
  				  <option value="3">县级合作方</option>
  				</select>
  			  </div>
  			</div> -->
  		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">金牌小卫士每月新增数量（人）</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text"  class="form-control" id="quantity" placeholder="金牌小卫士每月新增数量"></div>
  		  </div>
  		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">营收（元）</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text"  class="form-control" id="revenue" placeholder="营收"></div>
  		  </div>
  		 <div class="form-group">
  		   <label class="col-sm-4 control-label goods-lb-l">完成业绩分成比例（%）</label>
  		   <div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="complete_reward" placeholder="完成业绩分成比例"></div>
  		 </div>
  		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">未完成业绩分成比例（%）</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="unfinished_bonus" placeholder="未完成业绩分成比例"></div>
  		  </div>
		  <div class="form-group">
  			<label class="col-sm-4 control-label goods-lb-l">平台使用费</label>
  			<div class="col-sm-8 goods-lb-r"><input type="text" class="form-control" id="useFee" placeholder="平台使用费"></div>
  		  </div>
  	  </div>
  	  <div class="modal-footer">
  		<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  		<button type="button" class="btn btn-primary" id="entBtn">确认提交</button>
  	  </div>
  	</div><!-- /.modal-content -->
  </div>
</div>
  </body>
  <script src="js/jquery.min.js"></script>
  <script type="text/javascript" src="plugin/layer/layer.js"></script>
  <script type="text/javascript" src="js/cookie.js"></script>
  <script type="text/javascript" src="js/common.js"></script>
  <script type="text/javascript" src="js/ajax.js"></script>
  <script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
  <script type="text/javascript" src="js/bootstrap-paginator.js"></script>
  <script type="text/javascript" src="plugin/date/date.js"></script>
  <script type="text/javascript" src="plugin/date/date.zh-CN.js"></script>
  <script>
  $("document").ready(function(){
    tableList()
    // inputEmpty()
  })
  //分页
  var pageUrls =  serverURL + '/platform/queryPartnerLevel';
  function tableList(){
    var data = {
    	'page': page,
    	'pageSize': pagesize
      }
	  data.page = 1
	  ajax(
		  pageUrls,
		  data,
		  pageNumList,
		  'post',
		  'json'
	  )
  }
	$('#entinfo').on('hidden.bs.modal', function (e) {
		$('.modal-body input').val(null);
	})

  //数据渲染
  function OpendList(reg){
    var result = '';
    $('#integralList').empty();
    $('#integralList').append(
      '<tr>' +
      '<th>合作方等级名称</th>' +
      '<th>金牌小卫士每月新增数量</th>' +
      '<th>营收（元）</th>' +
      '<th>完成业绩分成比例（%）</th>' +
      '<th>未完成业绩分成比例（%）</th>' +
	  '<th>平台使用费</th>' +
      '<th>操作</th>' +
      '</tr>'
    );
    for (var i = 0; i < reg.data.list.length; i++) {
        var time = getMyDate(reg.data.list[i].createTime);
        result +=
               '<tr>'+
                 '<td>'+ reg.data.list[i].partnerName +'</td>'+
                 '<td>'+ reg.data.list[i].quantity +'</td>'+
                 '<td>'+ reg.data.list[i].revenue +'</td>'+
                 '<td>'+ reg.data.list[i].completeReward +'</td>'+
                 '<td>'+ reg.data.list[i].unfinishedBonus +'</td>'+
				 '<td>'+ reg.data.list[i].useFee +'</td>'+
                 '<td class="text-center">'+
				 '<button type="button" data-id="'+ reg.data.list[i].partnerId +'" class="btn btn-primary btn-sm listEnt" data-toggle="modal" data-target=".bs-example-modal-lg">编辑</button>'+
                 '</td>'+
               '</tr>'
    }
    $('#integralList').append(result)
  }
  	//删除
	// $(document).on('click', '.listDel', function() {
	//   	var id = $(this).attr('data-id')
	//   	layer.confirm('确定要删除这条信息吗？', {
	//      	btn: ['确定','取消'] //按钮
	//     }, function(){
	//     	deleteList (id)
	//     }, function(){
	//     });
	// })
	//详情
	$(document).on('click', '.listEnt', function() {
	  	var id = $(this).attr('data-id')
		var data = {
			'id':id,
		}
		var callback = function(res){
			$('#partner_id').val(res.data.partnerId)
			$('#partner_name').val(res.data.partnerName)
			$('#quantity').val(res.data.quantity)
			$('#revenue').val(res.data.revenue)
			$('#complete_reward').val(res.data.completeReward)
			$('#unfinished_bonus').val(res.data.unfinishedBonus)
			$('#useFee').val(res.data.useFee)
			tableList();
		}
		ajax(
			serverURL + '/platform/getPartnerLevelInfo',
			data,
			callback,
			'post',
			'json'
		)
	})

	//修改
	$('#entBtn').click(function(){
		var data = {
			'partnerId':$('#partner_id').val(),
			'partnerName':$('#partner_name').val(),
			'quantity':$('#quantity').val(),
			'revenue':$('#revenue').val(),
			'completeReward':$('#complete_reward').val(),
			'unfinishedBonus':$('#unfinished_bonus').val(),
			'useFee':$('#useFee').val()
		}
		var callback = function(res){
			$('#entinfo').modal('hide')
			tableList();
		}
		ajax(
			serverURL + '/platform/editPartnerLevel',
			data,
			callback,
			'post',
			'json'
		)
	})

	//删除
	// function deleteList(id){
	// 	$.ajax({
	// 		url: serverURL +  '/member/delPartnerLevel',
	// 		type: "post",
	// 		dataType: "json",
	// 		data: {
	// 		  'ids':id,
	// 		},
	// 		success: function (data) {
	// 			console.log(data.msg)
	// 			layer.msg(data.msg)
	// 			if (data.code == 400) {
	// 				alert("登陆超时请重新登陆")
	// 				window.location.href = "login.html";
	// 			}else if (data.code == 200) {
	// 				integralListPaga();
	// 			}
	// 		}
	// 	});
	// }
  </script>
</html>
